#include<bits/stdc++.h>
using namespace std;
const int N = 5010,E = 1.5e5+10;
const int P = (N + E*2)*24;
bool sm;
struct WBLT{
    int fath[P];
    int son[P][2];
    int siz[P];
    int sw[P];
    int pcnt;
    int rub[P],rubp;
    int gen(){
        int now;
        if(rubp){
            now = rub[--rubp];
        }else{
            now = ++pcnt;
        }
        son[now][0] = son[now][1] = siz[now] = fath[now] = sw[now] = 0;
        return now;
    }
    int gen(int w){
        int now = gen();
        siz[now] = 1;
        sw[now] = w;
        return now;
    }
    #define ls(x) son[x][0]
    #define rs(x) son[x][1]
    void push_up(int now){
        siz[now] = siz[ls(now)] + siz[rs(now)];
        sw[now] = sw[ls(now)] + sw[rs(now)];
    }
    int gen(int x,int y){
        int now = gen();
        son[now][0] = x;
        son[now][1] = y;
        fath[x] = x;
        fath[y] = y;
        push_up(now);
        return now;
    }

    void balence(int &x){
        if(max(siz[ls(x)],siz[rs(x)]) < min(siz[ls(x)],siz[rs(x)])*3){
            return;
        }
        int lp = ls(x);
        int rp = rs(x);
        rub[++rubp] = x;
        if(siz[ls(x)] > siz[rs(x)]){
            int lpl = ls(lp);
            int lpr = rs(lp);
            rub[++rubp] = lp;
            if(siz[lpr] <= siz[lpl]*2){
                x = gen(lpl,gen(lpr,rp));
            }else{
                int lprl = ls(lpr);
                int lprr = rs(lpr);
                rub[++rubp] = lpr;
                x = gen(gen(lpl,lprl),gen(lprr,rp));
            }
        }else{
            int rpl = ls(rp);
            int rpr = rs(rp);
            rub[++rubp] = rp;
            if(siz[rpl] <= siz[rpr]*2){
                x = gen(gen(lp,rpl),rpr);
            }else{
                int rpll = ls(rpl);
                int rplr = rs(rpl);
                rub[++rubp] = rpl;
                x = gen(gen(lp,rpll),gen(rplr,rpr));
            }
        }
    }
    int merges(int x,int y){
        if(!x || !y){
            return x + y;
        }
        if(max(siz[x],siz[y]) <= min(siz[x],siz[y])*3){
            return gen(x,y);
        }
        if(siz[x] > siz[y]){
            int lpx = ls(x);
            int rpx = rs(x);
            rub[++rubp] = x;
            int now = gen(lpx,merges(rpx,y));
            balence(now);
            return now;
        }else{
            int lpy = ls(y);
            int rpy = rs(y);
            rub[++rubp] = y;
            int now = gen(merges(y,lpy),rpy);
            balence(now);
            return now;
        }
    }
    void split(int now,int rnk,int &x,int &y){
        if(!rnk){
            x = 0;
            y = now;
            return;
        }
        if(!son[now][0]){
            x = now;
            y = 0;
            return;
        }
        int lpn = ls(now),rpn = rs(now);
        rub[++rubp] = now;
        if(siz[lpn] >= rnk){
            split(lpn,rnk,x,y);
            y = merges(y,rpn);
        }else{
            split(rpn,rnk - siz[lpn],x,y);
            x = merges(lpn,x);
        }
    }
    int find_rot(int now){
        int p = 0;
        while(now){
            p = now;
            now = fath[now];
        }
        return p;
    }
    void update(int now){
        while(now)
        {
            now = fath[now];
            if(now){
                push_up(now);
            }
        }
    }
    int cles(int now){
        int res = 0;
        while(fath[now])
        {
            if(rs(fath[now]) == now){
                res += siz[ls(fath[now])];
            }
            now = fath[now];
        }
        return res;
    }
} wb;
bool em;
int make_rot(int x){
    int lesc = wb.cles(x);
    int a,b;
    wb.split(x,lesc,a,b);
    return wb.merges(b,a);
}

int link(int u,int v,int et,int eb){
    int r1 = make_rot(u);
    int r2 = make_rot(v);
    return wb.merges(wb.merges(r1,et),wb.merges(r2,eb));
}
pair<int,int> cut(int et,int eb){
    int rt = wb.find_rot(et);
    int r1 = wb.cles(et) + 1;
    int r2 = wb.cles(eb) + 1;
    if(r1 > r2){
        swap(r1,r2); 
    }
    int a,b,c,d,e;
    wb.split(rt,r2,d,e);
    wb.split(d,r2 - 1,c,d);
    wb.split(c,r1,b,c);
    wb.split(b,r1 - 1,a,b);
    return make_pair(wb.merges(a,e),c);
}
int ndp[20][N];
vector<int> nes[20][N];

int ecnt = 1;
int edp[20][N*2];
bool connected(int x,int y){   
    int r1 = wb.find_rot(ndp[0][x]);
    int r2 = wb.find_rot(ndp[0][y]);
    return r1 == r2;
}
void connect(int x,int y){
    ++ecnt;
    edp[0][ecnt] = wb.gen(1);
    ++ecnt;
    edp[0][ecnt] = wb.gen(1);
    nes[0][x].push_back(ecnt - 1);
    nes[0][y].push_back(ecnt);
    if(!connected(x,y)){
        
    }
}
int main(){
    cerr<<(&em-&sm)/1048576.0<<'\n';
    int n,m;
    cin>>n>>m;
    for(int j = 0;j < 20;j++){
        for(int i = 1;i<=n;i++){
            ndp[i][j] = wb.gen(0);
        }
    }
    for(int i = 1;i<=m;i++){
        int op;
        cin>>op;
        if(op == 1){
        }else if(op == 2){
        }else{
        }
    }
}